package com.hhss.qishi.mapper.system.provider;

import org.apache.ibatis.jdbc.SQL;

/**
 * 权限
 * Sql构造器
 * Author :Administrator
 * Date   :2019-04-28 18:32.
 */
public class PermissionProvider {

	private static String SQL_ENTITY = "id, uuid,"
			+ " pid, permission_name as permissionName, permission_type AS permissionType,"
			+ " permission_text AS permissionText, sort, "
			+ " status, create_user AS createUser, create_time AS createTime, last_update_user AS lastUpdateUser,"
			+ " last_update_time AS lastUpdateTime, create_user AS createUser, last_update_user AS lastUpdateUser";

	private static String TABLE_NAME = "sys_permission";

	public String getEntityByIdSQL(final Long id){
		return new SQL(){{
			SELECT(SQL_ENTITY);
			FROM(TABLE_NAME);
			WHERE("id IN(SELECT permission_id FROM sys_permission_role WHERE role_id = #{id})");
		}}.toString();
	}
}
